package com.youdoneed.friends.feign;

import com.youdoneed.base.application.ResultMessage;
import com.youdoneed.friends.model.Contact;
import com.youdoneed.friends.vo.AppSearchResult;
import com.youdoneed.friends.vo.ImgComparisonResult;
import com.youdoneed.friends.vo.UserRelationsVO;
import com.youdoneed.user.model.User;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 说明。
 *
 * @author Ewing
 * @date 2017/4/26
 */
@FeignClient(value = "friends", fallback = FriendsFallback.class)
public interface FriendsClient {

    /**
     * 注册环信用户。
     */
    @RequestMapping(value = "/user/singleRegister", method = RequestMethod.POST)
    ResultMessage<String> singleRegister(@RequestParam("username") String username,
                                         @RequestParam("password") String password);

    /**
     * 获取环信用户（单个）。
     */
    @RequestMapping(value = "/user/getSingleUser", method = RequestMethod.POST)
    ResultMessage<String> getSingleUser(@RequestParam("username") String username);

    /**
     * 修改环信用户昵称。
     */
    @RequestMapping(value = "/user/updateNickName", method = RequestMethod.POST)
    ResultMessage<String> updateNickName(@RequestParam("username") String username,
                                         @RequestParam("nickname") String nickname);

    /**
     * 删除单个环信用户。
     */
    @RequestMapping(value = "/user/deleteSingleUser", method = RequestMethod.POST)
    ResultMessage<String> deleteSingleUser(@RequestParam("username") String username);

    /**
     * 给环信用户添加好友。
     */
    @RequestMapping(value = "/user/addUserFriend", method = RequestMethod.POST)
    ResultMessage<String> addUserFriend(@RequestParam("owner_username") String owner_username,
                                        @RequestParam("friend_username") String friend_username);

    /**
     * 查看好友。
     */
    @RequestMapping(value = "/user/checkUserFriend", method = RequestMethod.POST)
    ResultMessage<String> checkUserFriend(@RequestParam("owner_username") String owner_username);

    /**
     * 获取 APP 中所有的群组（可分页）。
     */
    @RequestMapping(value = "/user/getGroupUser", method = RequestMethod.POST)
    ResultMessage<String> getGroupUser(@RequestParam("limit") String limit,
                                       @RequestParam("cursor") String cursor);

    /**
     * 创建一个群组。
     */
    @RequestMapping(value = "/user/createGroupUser", method = RequestMethod.POST)
    ResultMessage<String> createGroupUser(@RequestBody Map<String, Object> map);

    /**
     * 删除群组。
     */
    @RequestMapping(value = "/user/deleteGroup", method = RequestMethod.POST)
    ResultMessage<String> deleteGroup(@RequestParam("group_id") String group_id);

    /**
     * 添加群组成员[批量]。
     */
    @RequestMapping(value = "/user/addGroupUsers", method = RequestMethod.POST)
    ResultMessage<String> addGroupUsers(@RequestParam("chatgroupid") String chatgroupid,
                                        @RequestBody Map<String, Object> usernames);

    /**
     * 获取群组所有成员。
     */
    @RequestMapping(value = "/user/getGroupUsers", method = RequestMethod.POST)
    ResultMessage<String> getGroupUsers(@RequestParam("group_id") String group_id);

    /**
     * 移出群组成员[单个]。
     */
    @RequestMapping(value = "/user/deleteGroupUser", method = RequestMethod.POST)
    ResultMessage<String> deleteGroupUser(@RequestParam("group_id") String group_id,
                                          @RequestParam("username") String username);

    /**
     * 添加群组成员[单个]。
     */
    @RequestMapping(value = "/user/addGroupUser", method = RequestMethod.POST)
    ResultMessage<String> addGroupUser(@RequestParam("group_id") String group_id,
                                       @RequestParam("username") String username);

    /**
     * 获取群组详情。
     */
    @RequestMapping(value = "/user/getGroupDetails", method = RequestMethod.POST)
    ResultMessage<String> getGroupDetails(@RequestBody List<String> group_ids);

    /**
     * 修改群组信息。
     */
    @RequestMapping(value = "/user/modifyGroupDetails", method = RequestMethod.POST)
    ResultMessage<String> modifyGroupDetails(
            @RequestParam("group_id") String group_id, @RequestParam("groupname") String groupname,
            @RequestParam("description") String description, @RequestParam("maxusers") String maxusers);

    /**
     * 根据用户id查询好友列表
     */
    @RequestMapping(value = "/friends/findFriendsList", method = RequestMethod.POST)
    ResultMessage<List<Map<String, Object>>> findFriendsList(
            @RequestParam(value = "userId", required = false) String userId);

    /**
     * 根据用户id查询好友列表(news专用)
     */
    @RequestMapping(value = "/friends/findFriends", method = RequestMethod.POST)
    ResultMessage<List<User>> findFriends();

    /**
     * 根据用户id查询好友id列表
     *
     * @param type 1、查找好友id，2、查找黑名单id、3、两者都要
     */
    @RequestMapping(value = "/friends/findFriendIds", method = RequestMethod.POST)
    ResultMessage<UserRelationsVO> findFriendIds(@RequestParam(value = "type") Integer type);

    /**
     * 后台自动加好友
     */
    @RequestMapping(value = "/friends/autoAddFriends", method = RequestMethod.POST)
    ResultMessage<String> autoAddFriends();

    /**
     * 判断是否为好友关系（user项目用）
     */
    @RequestMapping(value = "/friends/isFriendOrNot", method = RequestMethod.POST)
    ResultMessage<List<String>> isFriendOrNot(@RequestBody String[] friendIds);

    /**
     * 人脸特征提取
     */
    @RequestMapping(value = "/face/genImgFeature", method = RequestMethod.POST)
    ResultMessage<ImgComparisonResult> genImgFeature(@RequestParam("pathName") String pathName);

    /**
     * 获取用户手机通讯录
     */
    @RequestMapping(value = "/friends/getContacts", method = RequestMethod.POST)
    ResultMessage<List<Contact>> getContacts();

    /**
     * 用户登录时判断是否曾经有人coolface我
     * @return AppSearchResult
     * @author ld
     * @date 2017.11.13
     */
    @RequestMapping(value = "/face/whoCoolfaceMe", method = RequestMethod.POST)
    ResultMessage<AppSearchResult> whoCoolfaceMe(@RequestHeader("Authorization") String token);

}
